home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: class declaration question
- Date: 22 Jan 1996 16:44:18 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan22114418@g7240065.bridge.bst.bls.com>
- References: <4dphp6$1bp@noc2.drexel.edu> <4drakm$hnu@grid.direct.ca>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: qjackson@direct.ca's message of Sat, 20 Jan 1996 18:02:09 GMT
-
- In article <4drakm$hnu@grid.direct.ca> qjackson@direct.ca writes:
-
- : st918h5w@dunx1.ocs.drexel.edu (Jonathan Juniman) wrote:
-
- :> Is it necessary to do this:
-
- :> class SomeClass
- :> {
- :> public:
- :> void Somefunction(int SomeParameter);
- :> }
-
- :> or is it just as legal to do this:
- :> class SomeClass
- :> {
- :> public:
- :> void SomeFunction(int);
- :> }
-
- :> The latter seems to be the convention, but why does the compiler need to
- :> know the name of SomeFunction's argument? Isn't it sufficient to know the
- :> type of Somefunction's argument (namely, int)?
-
- Both are valid. And neither one more valid than the other for the compiler.
- The compiler does not need to know the name of the parameter
- but a fellow programmer who decides to use your class might. Not only is
- the code for a compiler to generate 1's and 0's from but it also to
- communicate with fellow programmers and sensibly named parameters can
- go a long way to informing other programmers what exactly the parameter
- is for.
-
- : The following will compile under Turbo C++ 3.00 -- I don't know what
- : the standard is --
-
- : class foo
- : {
- : public:
- : void bar (int);
- : };
-
- : void foo::bar (int baz)
- : {
- : // do someFoobar
- : ++baz;
- : }
-
- : void main (void)
- : {
- : foo Chocolate;
- : Chocolate.bar(10);
- : }
-
- The following will compile but has undefined results when run.
- The standard says that
-
- void main(void)
-
- has undefined behaviour and should be declared
-
- int main(void)
- or
- int main(int argc, char* argv[])
-
- Regards
-
- -A.
- --
- | A.Champion |
-